﻿$(document).ready(function () {

    //Service location
    $("#autocompleteService").kendoComboBox({
        dataTextField: "Name",
        dataValueField: "ID",
        dataSource: new kendo.data.DataSource({
            transport: {
                read: "/Event/GetLocationsJson" // url to server method which returns data
            }
        }),
        value: "1000"
    });

    //onchange event
    $("#autocompleteService").data("kendoComboBox").bind("change", function (e) {
        var autoComplete = $("#autocompleteService").data("kendoComboBox");
        var item = autoComplete.value();
        var hiddenField = $('#hdnServiceID');
        hiddenField.innerHTML = item;
        hiddenField.value = item;
    });


    //autocompleteReception
    $("#autocompleteReception").kendoComboBox({
        dataTextField: "Name",
        dataValueField: "ID",
        dataSource: new kendo.data.DataSource({
            transport: {
                read: "/Event/GetLocationsJson" // url to server method which returns data
            }
        }),
        value: "1000"
    });

    //onchange event
    $("#autocompleteReception").data("kendoComboBox").bind("change", function (e) {
        var autoComplete = $("#autocompleteReception").data("kendoComboBox");
        var item = autoComplete.value();
        var hiddenField = $('#hdnReceptionID');
        hiddenField.innerHTML = item;
        hiddenField.value = item;
    });





    //CLient
    $("#autocompleteClient").kendoComboBox({
        dataTextField: "FullName",
        dataValueField: "ID",
        dataSource: new kendo.data.DataSource({
            transport: {
                read: "/Client/GetAllJson" // url to server method which returns data
            }
        }),
        value: "1000"
    });

    //set initial value
    $("#autocompleteClient").data("kendoComboBox").value("1000");

    //onchange event
    $("#autocompleteClient").data("kendoComboBox").bind("change", function (e) {
        var autoComplete = $("#autocompleteClient").data("kendoComboBox");
        var item = autoComplete.value();
        var hiddenField = $('#hdnClientID');
        hiddenField.innerHTML = item;
        hiddenField.value = item;
    });

    //$("#autocompleteClient").kendoAutoComplete({
    //    dataTextField: "FullName",
    //    animation: {
    //        open: {
    //            effects: "fadeIn",
    //            duration: 300,
    //            show: true
    //        }
    //    },
    //    dataSource: new kendo.data.DataSource({
    //        transport: {
    //            read: "/Client/GetAllJson" // url to server method which returns data
    //        }
    //    })
    //});

    //Date and time pickers
    $(".timepicker").kendoTimePicker({
        animation: {
            close: {
                effects: "fadeOut",
                duration: 300,
                hide: true,
                show: false
            }
        }
    });
    $(".datepicker").kendoDatePicker({
        animation: {
            open: {
                effects: "fadeIn",
                duration: 300,
                show: true
            }
        }
    });

});